package edu.uts.reekie.designer.actions;

import java.util.List;

import org.eclipse.gef.EditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.ui.IWorkbenchPart;

import edu.uts.reekie.designer.model.AbstractConnector;

public class ClearConnectorLabelAction extends ConnectorLabelAction {
	

	public static final String NORMAL = "Clear Connector Label";

	public ClearConnectorLabelAction(IWorkbenchPart part) {
		super(part);
		// TODO Auto-generated constructor stub
	}

	protected boolean canPerformAction(AbstractConnector connector) {
		// return true if the connector has a label value
		
		if (connector.getLabel()!=null)
			return true;
		
		return false;
	
	}

	protected String generateId() {
		return NORMAL;
	}
	
	protected  Command getCommand() {
		
		List<?> editparts = getSelectedObjects();
		CompoundCommand cc = new CompoundCommand();
		cc.setDebugLabel("Clear Connector Label");//$NON-NLS-1$
		for (int i=0; i < editparts.size(); i++) {
			EditPart part = (EditPart)editparts.get(i);
			cc.add(part.getCommand(request));
		}
		return cc;
	}

}
